<template>
  <view class="container">
    <!-- 头部机构信息 -->
    <view class="header">
      <text class="hospital">种鹅选育中心</text>
      <text class="time">{{ currentTime }}</text>
    </view>

    <!-- 系统标题 -->
    <view class="title-box">
      <text class="sub-title">种鹅健康监测上报</text>
      <text class="main-title">每日数据打卡系统</text>
    </view>

    <!-- 登录表单 -->
    <view class="form">
      <input 
        class="input-item" 
        placeholder="请输入员工编号" 
        v-model="staffId" 
        placeholder-class="placeholder"
      />
      <input 
        class="input-item" 
        placeholder="请输入姓名" 
        v-model="staffName"
        placeholder-class="placeholder"
      />
      <button 
        class="login-btn" 
        @click="handleLogin"
      >登 录</button>
    </view>

    <!-- 技术支持信息 -->
    <view class="footer">
      <text class="tech-support">技术支持：种鹅选育中心信息部 农业科技公司</text>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { loginByJson } from '../../api/login.js'

// 当前时间处理
const currentTime = ref('');
const updateTime = () => {
  const now = new Date();
  const hours = now.getHours().toString().padStart(2, '0');
  const minutes = now.getMinutes().toString().padStart(2, '0');
  currentTime.value = `${hours}:${minutes}`;
};
setInterval(updateTime, 1000);
updateTime();

// 登录逻辑
const staffId = ref('');
const staffName = ref('');

const handleLogin = () => {
  if (!staffId.value || !staffName.value) {
    uni.showToast({
      title: '请填写完整信息',
      icon: 'none'
    });
    return;
  }
  
  uni.switchTab({
    url: '/pages/index/index',
    success() {
      console.log('登录成功，跳转首页');
    }
  });
};
</script>

<style scoped>
.container {
  padding: 40rpx;
  min-height: 100vh;
  background: #f5f5f5;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 60rpx;
}

.hospital {
  font-size: 36rpx;
  color: #333;
  font-weight: bold;
}

.time {
  font-size: 32rpx;
  color: #666;
}

.title-box {
  margin: 80rpx 0 100rpx;
  text-align: center;
}

.sub-title {
  display: block;
  font-size: 34rpx;
  color: #888;
  margin-bottom: 20rpx;
}

.main-title {
  font-size: 48rpx;
  color: #2a8bfa;
  font-weight: bold;
}

.form {
  background: #fff;
  padding: 60rpx 40rpx;
  border-radius: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
}

.input-item {
  height: 100rpx;
  line-height: 100rpx;
  border-bottom: 2rpx solid #eee;
  font-size: 34rpx;
  padding-left: 20rpx;
  margin-bottom: 40rpx;
}

.placeholder {
  color: #ccc;
}

.login-btn {
  background: #2a8bfa;
  color: #fff;
  font-size: 36rpx;
  height: 90rpx;
  line-height: 90rpx;
  border-radius: 45rpx;
  margin-top: 60rpx;
}

.footer {
  position: fixed;
  bottom: 40rpx;
  width: 100%;
  text-align: center;
}

.tech-support {
  font-size: 24rpx;
  color: #999;
}
</style>